<%-- 
    Document   : myjsp
    Created on : Oct 17, 2009, 2:03:45 PM
    Author     : balbir kaur
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="../include/quiz.css" rel="stylesheet" media="screen"  type="text/css"/>
        <title>CSQUIZ:Twitter status update</title>
    </head>
    <body>


        <%@ page import="org.netbeans.saas.*, org.netbeans.saas.twitter.*" %>


        <s:include value="../include/header.html"/>
        <div id="allcontent">
            <div id="leftsidebar">
                <ul><li><em><a href="<s:url value='show.action'/>"> Take Quiz Again </a></em></li></ul><br/>
            </div>
            <div id="main">
                <s:set name="message" value="%{message}" scope="request"/>


                <%   StringBuffer p = new StringBuffer();
                     p.append((String) application.getAttribute("tweetstart") + " ");
                     String message = "I Scored" + (String) request.getAttribute("message");
                     p.append(message + " ");
                     p.append((String) application.getAttribute("tweetend"));
                     
                         try {
                             String status = p.toString();
                             String inReplyToStatusId = null;
                             String format = "xml";

                             RestResponse result = TwitterWhatAreYouDoingService.updateStatus(request, response, status, inReplyToStatusId, format);
                             if (result.getDataAsObject(twitter.whatareyoudoingservice.twitterresponse.StatusType.class) instanceof twitter.whatareyoudoingservice.twitterresponse.StatusType) {
                                 twitter.whatareyoudoingservice.twitterresponse.StatusType resultObj = result.getDataAsObject(twitter.whatareyoudoingservice.twitterresponse.StatusType.class);
                             } else if (result.getDataAsObject(twitter.whatareyoudoingservice.twitterresponse.NilClasses.class) instanceof twitter.whatareyoudoingservice.twitterresponse.NilClasses) {
                                 twitter.whatareyoudoingservice.twitterresponse.NilClasses resultObj = result.getDataAsObject(twitter.whatareyoudoingservice.twitterresponse.NilClasses.class);
                             }
                             //TODO - Uncomment the print Statement below to print result.
                             out.println("The result was posted successfuly ");
                         } catch (Exception ex) {
                             ex.printStackTrace();
                         }
                                          
                %>
            </div>
        </div>
        <s:include value="../include/footer.jsp"/>
    </body>
</html>
